package com.ft.oa.mapper.approval;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ft.oa.domain.approval.ApplyForApproval;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 审批dao
 * @author liyansheng
 * @ClassName ApplyForApprovalMapper
 * @date 2022-1-17 15:50:27
 */
public interface ApplyForApprovalMapper extends BaseMapper<ApplyForApproval> {
    /**
     * 更新业务表审批状态
     * @param table 业务表表名
     * @param approvalColumn 业务表审核字段名
     * @param value  审核状态 0-审核中  1-通过  2-驳回
     * @param id 主键
     * @return
     */
    @Update("update ${table} set ${approvalColumn} = ${value} where id = #{id}")
    int updateApprovalStatus(@Param("table") String table,@Param("approvalColumn") String approvalColumn,@Param("value") int value,@Param("id") Long id);

    /**
     * 根据主键查询业务表对应业务名称
     * @param table
     * @param businessNameColumn
     * @param id
     * @return
     */
    @Select("select ${businessNameColumn} as relationName from ${table} where id = #{id} ")
    String getRelationName(@Param("table") String table,@Param("businessNameColumn") String businessNameColumn,@Param("id") Long id);

}
